<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // var obj1 = {name:'小红', age:18, sex:'女', say(text){console.log(text);}}
        // obj1['say']('你好啊! !!');

        // function createObj(name, age, sex) {
        //     var obj = new Object();
        //     obj.name = name;
        //     obj.age = age
        //     obj.sex = sex;
        //     obj.toString = function() {
        //         console.log('name = ' + name + ' age = ' + age + ' sex = ' + sex);
        //     }
        //     return obj;
        // }
        
        var obj1 = createObj("小红", 18, '女');
        var obj2 = createObj("小明", 19, '男');
        var obj3 = createObj("小蓝", 17, '女');
        obj1.toString();
        obj2.toString();
        obj3.toString();
        
        function Person(name, age, sex) {
            this.name = name;
            this.age = age;
            this.sex = sex;
            this.toString = function() {
                console.log('name = ' + name + ' age = ' + age + ' sex = ' + sex);
            }
        }
        var p = new Person('赵四', 18, '女');
        p.toString();
    </script>
</body>
</html>